
package com.ruoyi.web.controller.prevention;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.PreventionAlert;
import com.ruoyi.system.service.PreventionAlertService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("preventionAlert")
public class PreventionAlertController extends BaseController {


    @Resource
    private PreventionAlertService preventionAlertService;

    @GetMapping("/list")
    public TableDataInfo queryByPage(PreventionAlert preventionAlert) {
        startPage();
        List<PreventionAlert> preventionAlerts = this.preventionAlertService.queryByPage(preventionAlert);
        return getDataTable(preventionAlerts);
    }

    @GetMapping("{id}")
    public ResponseEntity<PreventionAlert> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.preventionAlertService.queryById(id));
    }

    @PostMapping
    public ResponseEntity<PreventionAlert> add(PreventionAlert preventionAlert) {
        return ResponseEntity.ok(this.preventionAlertService.insert(preventionAlert));
    }

    @PutMapping
    public ResponseEntity<PreventionAlert> edit(PreventionAlert preventionAlert) {
        return ResponseEntity.ok(this.preventionAlertService.update(preventionAlert));
    }

    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.preventionAlertService.deleteById(id));
    }

}


